/*
 * 		Author : Xerxes
 * 		Program: 
 * 		Created On : 26.09.2011 07:13:30 BDT
 *      "I have not failed, I have just found 10000 ways that won't work.
 * 
*/


#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define VI vector< int >
#define CI( x ) scanf("%d",&x)
#define CL( x ) scanf("%lld",&x)
#define CD( x ) scanf("%lf",&x )
#define fo(i,st,ed) for(int i = st ; i < ed ; ++i )
#define foE(i,st,ed) for(int i = st ; i <= ed ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define tp pair< int, pair<int,int> >
#define mmk( x, y , z ) mk( x, mk( y, z ) )

inline void wait( double seconds ){
    double endtime = clock()+( seconds* CLOCKS_PER_SEC );
    while( clock() < endtime ){
        ;
    }
}
vector< vector<int> >  young,old;

struct NODE{
	char a;
	char u;
	int x;
	int y;
	int cost;
	NODE( char a_, char u_, int x_, int y_, int cost_):
	a(a_),u(u_),x(x_),y(y_),cost(cost_){;}
};

vector< NODE> vt;
map< string, int > id;
map< int ,string > revid;
int N;
int sxS,sxM;
int id_;
vector< vector< pair<int,int> > > goS,goM;
inline void Read(){
		char a;
		char u;
		string x;
		string y;
		int cost;
		id.clear();
		revid.clear();
		vt.clear();
		id_=0;
		fo(i,0,N){
			cin>>a>>u>>x>>y>>cost;
			if( id.count(x)<1 ){
				id[x] = id_;
				revid[ id_ ] = x;
				++id_;
			}
			if( id.count(y)<1 ){
				id[y] = id_;
				revid[ id_ ] = y;
				++id_;
			}
			vt.pb( NODE(a,u,id[x],id[y],cost) );
			
		}
		
		goS.assign( id_+5, vector<pair<int,int> >() );
		goM.assign( id_+5, vector<pair<int,int> >() );
		
		for(int i=0,j=SZ(vt);i<j;++i){
				if( vt[i].a=='Y' ) {
					goS[ vt[i].x ].pb( mk(vt[i].y, vt[i].cost) );
					if( vt[i].u=='B' ){
						goS[ vt[i].y ].pb( mk(vt[i].x, vt[i].cost) );
					}
				}
				else{
					goM[ vt[i].x ].pb( mk(vt[i].y, vt[i].cost) );
					if( vt[i].u=='B' ){
						goM[ vt[i].y ].pb( mk(vt[i].x, vt[i].cost) );
					}
				}
		}
		cin>>x>>y;
		if( id.count(x) < 1 ) {
			id[x] = id_;
			revid[ id_ ] = x;
			++id_;
		}
		if( id.count(y) < 1 ){
			id[y] = id_;
			revid[ id_ ] = y;
			++id_;
		}
		sxS =  id[x] ;
		sxM =  id[y] ;
}
int DS[ 1000 ];
int FS[ 1000 ];
int DM[ 1000 ];
int FM[ 1000 ];

const int inf = (int)1e6;
inline void djS(int sx){
	fo(i,0,1000){
		DS[i] = inf;
	}
	SET(FS,0);
	set< pair<int,int >, less< pair<int,int> > > pq;
	pq.insert( mk(0,sx) );
	DS[sx] = 0;
	
	 while(pq.empty()==false){
		 int father = pq.begin()->s;
		 pq.erase( pq.begin() );
		 
		 if( FS[ father ] )continue;
		 vector< pair<int,int> > cango = goS[father];
		 
		 for(int i=0,j=SZ(cango); i<j; ++i){
			 int child = cango[i].f;
			 int dist = cango[i].s;
		
			 int nw_dist = dist+DS[father];
			 if( FS[child]==0 && (nw_dist < DS[child]) ) {
				 DS[child]=nw_dist;
				 pq.insert( mk(nw_dist, child) );
			 }
			 
		 }
		 
		 FS[ father ] = 1;
	 }
}


inline void djM(int sx){
	fo(i,0,1000){
		DM[i] = inf;
	}
	SET(FM,0);
	set< pair<int,int >, less< pair<int,int> > > pq;
	pq.insert( mk(0,sx) );
	DM[sx] = 0;
	
	 while(pq.empty()==false){
		 int father = pq.begin()->s;
		 pq.erase( pq.begin() );
		 
		 if( FM[ father ] )continue;
		 vector< pair<int,int> > cango = goM[father];
		 
		 for(int i=0,j=SZ(cango); i<j; ++i){
			 int child = cango[i].f;
			 int dist = cango[i].s;
		
			 int nw_dist = dist+DM[father];
			 if( FM[child]==0 && (nw_dist < DM[child]) ) {
				 DM[child]=nw_dist;
				 pq.insert( mk(nw_dist, child) );
			 }
			 
		 }
		 
		 FM[ father ] = 1;
	 }
}

inline bool cmp(string s1, string s2){
	return lexicographical_compare(s1.begin(),s1.end(),s2.begin(),s2.end());
}
inline void Proc(){
	
	djS(sxS);
	djM(sxM);
	
	int best = inf;
	for(int i=0; i<id_;++i ){
		//printf("%3d %3d\n",DS[i]>=inf ? -1 : DS[i],DM[i]>=inf ? -1 : DM[i] );
		int var = DS[i]+DM[i];
		if( var < best ){
			best = var ;
		}
	}
	vector< string > retval;
	
	if( best < inf ){
		fo(i,0,id_){
			if( best == DS[i]+DM[i] ){
				retval.pb( revid[i] );
			}
		}
		sort(retval.begin(),retval.end(), cmp);
		cout<<best;
		for(int i=0,j=SZ(retval);i<j;++i){
			cout<<" "<<retval[i];
		}
		cout<<"\n";
	}
	else{
		printf("You will never meet.\n");
	}
	//printf("\n");
}
int main(){
    #ifndef ONLINE_JUDGE
        freopen("in","rt",stdin);
    #endif
    
    while( scanf("%d",&N)==1 ){
		if( N==0 )break;
		Read();
		Proc();
	}

return 0;
}


